/**
 * Created by Administrator on 2017/9/2.
 */
var pattern = require('../CARD9/Card9').Pattern;
var patternMap = require('../CARD9/Card9').PatternSum;
var CompareFun = function(num,Gui,GTW){
    if(!Gui && num == pattern.DEVIL){
        return pattern.BITEN;
    }
    if(!GTW && num == pattern.NINELORD){
        return pattern.SKYONE;
    }

    if(num > pattern.PAIRGOOSE && num < pattern.PAIRTIGER){
        return pattern.PAIRBIGFIVE;
    }
    if(num > pattern.PAIRTIGER && num < pattern.PAIR1FIVE){
        return pattern.PAIRTIGER;
    }
    return num;
}
var choiceBest=function(cards,Gui,GTW){
    var list = [[0,1,2,3],[0,2,1,3],[0,3,1,2],[1,2,0,3],[1,3,0,2],[2,3,0,1]];
    var most = pattern.BITEN;
    var selectCardsPosition = [];
    list.forEach(function(v){
        var temp = [cards[v[0]],cards[v[1]]];
        temp.sort();
        var codetemp = temp[0]+'l'+temp[1];
        var tempcode = CompareFun(patternMap[codetemp],Gui,GTW);
        if(tempcode <= most){
            most = tempcode;
            selectCardsPosition = v.slice(0);
        }
    });
    return selectCardsPosition;
}
module.exports = {
    ComparePatternFun:CompareFun,
    ChoiceBest:choiceBest,
};